<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\Config;
use think\Cookie;
use think\Hook;
use think\Session;
use think\Validate;

/**
 * 会员中心
 */
class User extends Frontend
{

    protected $layout = 'default';
    protected $noNeedLogin = ['login', 'register', 'third'];
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();
        $auth = $this->auth;

        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }

        $ucenter = get_addon_info('ucenter');
        if ($ucenter && $ucenter['state']) {
            include ADDON_PATH . 'ucenter' . DS . 'uc.php';
        }

        //监听注册登录注销的事件
        Hook::add('user_login_successed', function ($user) use ($auth) {
            $expire = input('post.keeplogin') ? 30 * 86400 : 0;
            Cookie::set('uid', $user->id, $expire);
            Cookie::set('token', $auth->getToken(), $expire);
        });
        Hook::add('user_register_successed', function ($user) use ($auth) {
            Cookie::set('uid', $user->id);
            Cookie::set('token', $auth->getToken());
        });
        Hook::add('user_delete_successed', function ($user) use ($auth) {
            Cookie::delete('uid');
            Cookie::delete('token');
        });
        Hook::add('user_logout_successed', function ($user) use ($auth) {
            Cookie::delete('uid');
            Cookie::delete('token');
        });
    }

    /**
     * 会员中心
     */
    public function index()
    {
        $this->view->assign('title', __('User center'));
        return $this->view->fetch();
    }

    /**
     * 注册会员
     */
    public function register()
    {
        $url = $this->request->request('url');
        if ($this->auth->id)
            $this->success(__('You\'ve logged in, do not login again'), $url);
        if ($this->request->isPost()) {
            $username = $this->request->post('username');
            $password = $this->request->post('password');
            $email = $this->request->post('email');
            $mobile = $this->request->post('mobile', '');
            $captcha = $this->request->post('captcha');
            $token = $this->request->post('__token__');
            $rule = [
                'username'  => 'require|length:3,30',
                'password'  => 'require|length:6,30',
                'email'     => 'require|email',
                'mobile'    => 'regex:/^1\d{10}$/',
                'captcha'   => 'require|captcha',
                '__token__' => 'token',
            ];

            $msg = [
                'username.require' => 'Username can not be empty',
                'username.length'  => 'Username must be 3 to 30 characters',
                'password.require' => 'Password can not be empty',
                'password.length'  => 'Password must be 6 to 30 characters',
                'captcha.require'  => 'Captcha can not be empty',
                'captcha.captcha'  => 'Captcha is incorrect',
                'email'            => 'Email is incorrect',
                'mobile'           => 'Mobile is incorrect',
            ];
            $data = [
                'username'  => $username,
                'password'  => $password,
                'email'     => $email,
                'mobile'    => $mobile,
                'captcha'   => $captcha,
                '__token__' => $token,
            ];
            $validate = new Validate($rule, $msg);
            $result = $validate->check($data);
            if (!$result) {
                $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
            }
            if ($this->auth->register($username, $password, $email, $mobile)) {
                $synchtml = '';
                ////////////////同步到Ucenter////////////////
                if (defined('UC_STATUS') && UC_STATUS) {
                    $uc = new \addons\ucenter\library\client\Client();
                    $synchtml = $uc->uc_user_synregister($this->auth->id, $password);
                }
                $this->success(__('Sign up successful') . $synchtml, $url ? $url : url('user/index'));
            } else {
                $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
            }
        }
        //判断来源
        $referer = $this->request->server('HTTP_REFERER');
        if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
            && !preg_match("/(user\/login|user\/register)/i", $referer)) {
            $url = $referer;
        }
        $this->view->assign('url', $url);
        $this->view->assign('title', __('Register'));
        return $this->view->fetch();
    }

    /**
     * 会员登录
     */
    public function login()
    {
        $url = $this->request->request('url');
        if ($this->auth->id)
            $this->success(__('You\'ve logged in, do not login again'), $url);
        if ($this->request->isPost()) {
            $account = $this->request->post('account');
            $password = $this->request->post('password');
            $keeplogin = (int)$this->request->post('keeplogin');
            $token = $this->request->post('__token__');
            $rule = [
                'account'   => 'require|length:3,50',
                'password'  => 'require|length:6,30',
                '__token__' => 'token',
            ];

            $msg = [
                'account.require'  => 'Account can not be empty',
                'account.length'   => 'Account must be 3 to 50 characters',
                'password.require' => 'Password can not be empty',
                'password.length'  => 'Password must be 6 to 30 characters',
            ];
            $data = [
                'account'   => $account,
                'password'  => $password,
                '__token__' => $token,
            ];
            $validate = new Validate($rule, $msg);
            $result = $validate->check($data);
            if (!$result) {
                $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
                return FALSE;
            }
            if ($this->auth->login($account, $password)) {
                $synchtml = '';
                ////////////////同步到Ucenter////////////////
                if (defined('UC_STATUS') && UC_STATUS) {
                    $uc = new \addons\ucenter\library\client\Client();
                    $synchtml = $uc->uc_user_synlogin($this->auth->id);
                }
                $this->success(__('Logged in successful') . $synchtml, $url ? $url : url('user/index'));
            } else {
                $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
            }
        }
        //判断来源
        $referer = $this->request->server('HTTP_REFERER');
        if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
            && !preg_match("/(user\/login|user\/register)/i", $referer)) {
            $url = $referer;
        }
        $this->view->assign('url', $url);
        $this->view->assign('title', __('Login'));
        return $this->view->fetch();
    }

    /**
     * 注销登录
     */
    function logout()
    {
        //注销本站
        $this->auth->logout();
        $synchtml = '';
        ////////////////同步到Ucenter////////////////
        if (defined('UC_STATUS') && UC_STATUS) {
            $uc = new \addons\ucenter\library\client\Client();
            $synchtml = $uc->uc_user_synlogout();
        }
        $this->success(__('Logout successful') . $synchtml, url('user/index'));
    }

    /**
     * 个人信息
     */
    public function profile()
    {
        $this->view->assign('title', __('Profile'));
        return $this->view->fetch();
    }

    /**
     * 修改密码
     */
    public function changepwd()
    {
        if ($this->request->isPost()) {
            $oldpassword = $this->request->post("oldpassword");
            $newpassword = $this->request->post("newpassword");
            $renewpassword = $this->request->post("renewpassword");
            $token = $this->request->post('__token__');
            $rule = [
                'oldpassword'   => 'require|length:6,30',
                'newpassword'   => 'require|length:6,30',
                'renewpassword' => 'require|length:6,30|confirm:newpassword',
                '__token__'     => 'token',
            ];

            $msg = [
            ];
            $data = [
                'oldpassword'   => $oldpassword,
                'newpassword'   => $newpassword,
                'renewpassword' => $renewpassword,
                '__token__'     => $token,
            ];
            $field = [
                'oldpassword'   => __('Old password'),
                'newpassword'   => __('New password'),
                'renewpassword' => __('Renew password')
            ];
            $validate = new Validate($rule, $msg, $field);
            $result = $validate->check($data);
            if (!$result) {
                $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
                return FALSE;
            }

            $ret = $this->auth->changepwd($newpassword, $oldpassword);
            if ($ret) {
                $synchtml = '';
                ////////////////同步到Ucenter////////////////
                if (defined('UC_STATUS') && UC_STATUS) {
                    $uc = new \addons\ucenter\library\client\Client();
                    $synchtml = $uc->uc_user_synlogout();
                }
                $this->success(__('Reset password successful') . $synchtml, url('user/login'));
            } else {
                $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
            }
        }
        $this->view->assign('title', __('Change password'));
        return $this->view->fetch();
    }
    
    
    public function apply(){
        $apply_id=$this->request->param('apply_id');
        $rec_id=$this->request->param('recruit_id');
        if(!$apply_id){
            $uid=$_COOKIE['uid'];
            if(checkRepeat('hs_recruit_apply', 'uid', $uid,'recruit_id',$rec_id)){
                $this->error('您已报名,请前往会员中心查看',url('myapply'));
            }
        }
        
        //banner图
        $ad_row=db('hs_ad')->where('ad_location=1')->find();//
        $this->assign('ad_row',$ad_row);
    
        $rec_row=db('hs_recruit')->where('recruit_id',$rec_id)->find();//招聘信息
        $post_list=db('hs_recruit_post')->where('recruit_id',$rec_id)->select();//招聘信息
        $this->assign('post_list',$post_list);
        $this->assign('rec_row',$rec_row);
    
        if($apply_id){
            $apply_row=model('Apply')->get($apply_id);
            $this->assign('apply_row',$apply_row);
        }
        //字段查询
        $column_list = db('hs_apply_columns')->where('column_id','in',$rec_row['columns_id'])->order('sort')->select();
        foreach ($column_list as &$column){
            if (in_array($column['column_type'],array('text','select','checkbox','radio'))){
                $column['column_options']=explode(',',$column['column_options']);
            }
        }
        $this->assign('column_list',$column_list);
    
        if ($this->request->isPost()) {
           $params = $this->request->post("row/a");
            if ($params) {
                if(empty($params['apply_id'])){
                    if(checkRepeat('hs_recruit_apply', 'apply_idcard', $params['apply_idcard'],'recruit_id',$params['recruit_id'])){
                        //echo 'IsExist';die;//重复报名
                        $this->error('不要重复报名');
                    }
                }
                try {
                    $params['uid']=$_COOKIE['uid'];
                    $params['status']='wait';
                    if(!empty($params['apply_id'])){
                        $result=model('Apply')->allowField(true)->save($params,['apply_id' => $params['apply_id']]);
                    }else{
                        $result=model('Apply')->allowField(true)->save($params);
                    }
                    if ($result !== false) {
                        $this->success('报名成功');//报名成功
                    } else {
                        $this->error('报名失败');//报名失败
                    }
                } catch (\think\exception\PDOException $e) {
                    $this->error($e->getMessage());
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }
        
        
        
        
        
        
        
        return $this->view->fetch();
    }
    
    /**
     * 我的申请
     */
    public function myapply()
    {
        if ($this->request->isAjax())
        {
            
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('pkey_name'))
            {
                return $this->selectpage();
            }
            $uid=$_COOKIE['uid'];
            $total = model('Apply')->where('uid',$uid)->count();
            $list = model('Apply')->where('uid',$uid)->select();
            foreach($list as &$ad){
                $ad['recruit_title']=db('hs_recruit')->where('recruit_id', 'eq', $ad['recruit_id'])->value('recruit_title');
                $ad['recruit_post_name']=db('hs_recruit_post')->where('post_id', 'eq', $ad['recruit_post_id'])->value('post_name');
                
            }
            $result = array("total" => $total, "rows" => $list);
            return json($result);
            }
            return $this->view->fetch();
            
    }
    /*选择支付  */
    public function pay(){
        $rec_id=$this->request->param('recruit_id');//招聘id
        $apply_id=$this->request->param('apply_id');//报名id
        $apply_row=db('hs_recruit_apply')->where('apply_id',$apply_id)->field("apply_id,recruit_post_id")->find();
        $apply_row['recruit_post']=db('hs_recruit_post')->where('post_id',$apply_row['recruit_post_id'])->value('post_name');
        
        $recruit_row=db('hs_recruit')->where('recruit_id',$rec_id)->field("recruit_id,recruit_title,exam_cost")->find();
       
        $this->assign('apply_row',$apply_row);
        $this->assign('recruit_row',$recruit_row);
        return $this->view->fetch();
    }
    /**
     * 生产准考证并下载
     *   */
    public function exam_down(){
        $recruit_id=$this->request->param('recruit_id');
        $apply_id=$this->request->param('apply_id');
        
        $recruit=db('hs_recruit')->where('recruit_id',$recruit_id)->find();
        $apply=db('hs_recruit_apply')->where('apply_id',$apply_id)->find();
        
        $content="
            <html>
            
            <head>
            <meta http-equiv=Content-Type content='text/html; charset=utf8'>
            <meta name=Generator content='Microsoft Word 15 (filtered)'>
            <style>
            <!--
             /* Font Definitions */
             @font-face
            	{font-family:宋体;
            	panose-1:2 1 6 0 3 1 1 1 1 1;}
            @font-face
            	{font-family:'Cambria Math';
            	panose-1:2 4 5 3 5 4 6 3 2 4;}
            @font-face
            	{font-family:Calibri;
            	panose-1:2 15 5 2 2 2 4 3 2 4;}
            @font-face
            	{font-family:'\@宋体';
            	panose-1:2 1 6 0 3 1 1 1 1 1;}
             /* Style Definitions */
             p.MsoNormal, li.MsoNormal, div.MsoNormal
            	{margin:0cm;
            	margin-bottom:.0001pt;
            	text-align:justify;
            	text-justify:inter-ideograph;
            	font-size:10.5pt;
            	font-family:'Calibri',sans-serif;}
            p.MsoHeader, li.MsoHeader, div.MsoHeader
            	{mso-style-link:'页眉 Char';
            	margin:0cm;
            	margin-bottom:.0001pt;
            	text-align:center;
            	layout-grid-mode:char;
            	border:none;
            	padding:0cm;
            	font-size:9.0pt;
            	font-family:'Calibri',sans-serif;}
            p.MsoFooter, li.MsoFooter, div.MsoFooter
            	{mso-style-link:'页脚 Char';
            	margin:0cm;
            	margin-bottom:.0001pt;
            	layout-grid-mode:char;
            	font-size:9.0pt;
            	font-family:'Calibri',sans-serif;}
            span.Char
            	{mso-style-name:'页眉 Char';
            	mso-style-link:页眉;}
            span.Char0
            	{mso-style-name:'页脚 Char';
            	mso-style-link:页脚;}
            .MsoChpDefault
            	{font-size:10.0pt;
            	font-family:'Calibri',sans-serif;}
             /* Page Definitions */
             @page WordSection1
            	{size:595.3pt 841.9pt;
            	margin:72.0pt 90.0pt 72.0pt 90.0pt;
            	layout-grid:15.6pt;}
            div.WordSection1
            	{page:WordSection1;}
            -->
            </style>
            
            </head>
            
            <body lang=ZH-CN style='text-justify-trim:punctuation'>
            
            <div class=WordSection1 style='layout-grid:15.6pt'>
            
            <p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
            
            <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width=569
             style='border-collapse:collapse;border:none'>
             <tr style='height:259.15pt'>
              <td width=569 valign=top style='width:427.0pt;border:solid windowtext 1.5pt;
              padding:0cm 5.4pt 0cm 5.4pt;height:259.15pt'>
              <p class=MsoNormal align=center style='text-align:center'><b><span
              style='font-size:22.0pt;font-family:宋体'>$recruit[recruit_title]</span></b></p>
              <p class=MsoNormal align=center style='text-align:center'><b><span
              style='font-size:22.0pt;font-family:宋体'>笔试准考证</span></b></p>
              <p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>姓</span></b><b><span lang=EN-US
              style='font-size:14.0pt;line-height:200%'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></b><b><span
              style='font-size:14.0pt;line-height:200%;font-family:宋体'>名：$apply[apply_name]</span></b></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>身份证号：</span></b><b><span lang=EN-US
              style='font-size:14.0pt;line-height:200%'>$apply[apply_idcard]</span></b></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>准考证号：</span></b><b><span lang=EN-US
              style='font-size:14.0pt;line-height:200%'>$apply[exam_num]</span></b></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>考试地点：$recruit[exam_addr]</span></b></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>&nbsp;</span></b></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>考</span></b><b><span lang=EN-US
              style='font-size:14.0pt;line-height:200%'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></b><b><span
              style='font-size:14.0pt;line-height:200%;font-family:宋体'>场：</span></b><b><span
              lang=EN-US style='font-size:14.0pt;line-height:200%'>$apply[exam_room]</span></b></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>座</span></b><b><span lang=EN-US
              style='font-size:14.0pt;line-height:200%'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></b><b><span
              style='font-size:14.0pt;line-height:200%;font-family:宋体'>号：</span></b><b><span
              lang=EN-US style='font-size:14.0pt;line-height:200%'>$apply[exam_seat_num]</span></b></p>
              <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
              line-height:200%;font-family:宋体'>考试时间：</span></b><b><span lang=EN-US
              style='font-size:14.0pt;line-height:200%'>$recruit[exam_time]</span></b></p>
              </td>
             </tr>
             <tr style='height:267.2pt'>
              <td width=569 valign=top style='width:427.0pt;border:solid windowtext 1.5pt;
              border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:267.2pt'>
              <p class=MsoNormal align=center style='text-align:center;line-height:150%'><span
              style='font-size:16.0pt;line-height:150%;font-family:宋体'>考生须知</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>一、考试前</span><span
              lang=EN-US>$recruit[exam_ready]</span><span style='font-family:宋体'>，考生凭本人准考证和身份证（有效期内），缺一不可，进入考场，对号入座，并将两证放到桌子右上角。身份证丢失的，只能凭临时身份证参加考试，户籍证明、学生证、驾驶证、户口本等其他证件均不能作为考试凭证。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>二、考生进入考场，只准带</span><span
              lang=EN-US>2B</span><span style='font-family:宋体'>铅笔、橡皮、钢笔、签字笔进入考场，不得携带任何书籍、资料、小抄、稿纸及通讯工具。严禁将各种电子、通信、计算、储存或其它设备带入座位。凡使用禁止自带的通讯设备或者具有计算、储存功能电子设备的，给于其取消本次考试资格的处理。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>三、笔试答题一律用蓝黑色钢笔、签字笔在给定的位置书写，考生不得在答题规定位置外填写姓名、准考证号或在试卷上作任何标记，如有发现一律按照违纪处理。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>四、考试开始</span><span
              lang=EN-US>$recruit[exam_after]</span><span style='font-family:宋体'>后，不得入场；考试期间，不得提前交卷、退场。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>五、考生要自觉遵守《考场纪律》，如有违纪、舞弊行为，试卷一律按零分处理。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>六、对因个人原因，错进考场、座错位置，或未按规定作答而影响考试成绩的，责任自负。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>七、准考证不准涂改或转借他人，以备将来使用。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>八、若准考证个人信息有误，务必在考试前与招考机构联系。</span></p>
              <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>提示：考生应在考试前一天熟悉考场地址和交通路线。</span></p>
              </td>
             </tr>
            </table>
            </div>
            
            </body>
            
            </html>";
            
        ob_start();
        echo $content;
        $data = ob_get_contents();
        ob_end_clean();
        $id=$apply['apply_id'];
        $word_name="public/exam/$id.doc";
        $fp=fopen($word_name,"wb");
        fwrite($fp,$data);
        fclose($fp);
        //更改状态
        $a['updatetime']=time();
        $a['status']='exam_downloaded';
        $apply=model('Apply')->where('apply_id',$id)->update($a);
        
        $p=config('view_replace_str')['__ROOT__'];
        $word_name=$_SERVER['HTTP_HOST']."/$p/".$word_name;
        //         dump($word_name);
        $this->redirect('http://'.$word_name);
    }
    /**面试准考证下载  */
    /**
     * 生产准考证并下载
     *   */
    public function interview_down(){
        $recruit_id=$this->request->param('recruit_id');
        $apply_id=$this->request->param('apply_id');
    
        $recruit=db('hs_recruit')->where('recruit_id',$recruit_id)->find();
        $apply=db('hs_recruit_apply')->where('apply_id',$apply_id)->find();
        $post_name=db('hs_recruit_post')->where('post_id',$apply['recruit_post_id'])->value('post_name');
        $content="
<html>

<head>
<meta http-equiv=Content-Type content='text/html; charset=utf8'>
<meta name=Generator content='Microsoft Word 15 (filtered)'>
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:'Cambria Math';
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:'\@宋体';
	panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:'Calibri',sans-serif;}
p.MsoHeader, li.MsoHeader, div.MsoHeader
	{mso-style-link:'页眉 Char';
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:center;
	layout-grid-mode:char;
	border:none;
	padding:0cm;
	font-size:9.0pt;
	font-family:'Calibri',sans-serif;}
p.MsoFooter, li.MsoFooter, div.MsoFooter
	{mso-style-link:'页脚 Char';
	margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:'Calibri',sans-serif;}
span.Char
	{mso-style-name:'页眉 Char';
	mso-style-link:页眉;}
span.Char0
	{mso-style-name:'页脚 Char';
	mso-style-link:页脚;}
.MsoChpDefault
	{font-size:10.0pt;
	font-family:'Calibri',sans-serif;}
 /* Page Definitions */
 @page WordSection1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	layout-grid:15.6pt;}
div.WordSection1
	{page:WordSection1;}
-->
</style>

</head>

<body lang=ZH-CN style='text-justify-trim:punctuation'>

<div class=WordSection1 style='layout-grid:15.6pt'>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>

<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width=569
 style='border-collapse:collapse;border:none'>
 <tr style='height:259.15pt'>
  <td width=569 valign=top style='width:427.0pt;border:solid windowtext 1.5pt;
  padding:0cm 5.4pt 0cm 5.4pt;height:259.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b><span
  style='font-size:22.0pt;font-family:宋体'>$recruit[recruit_title]</span></b></p>
  <p class=MsoNormal align=center style='text-align:center'><b><span
  style='font-size:22.0pt;font-family:宋体'>面试准考证</span></b></p>
  <p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
  <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
  line-height:200%;font-family:宋体'>姓</span></b><b><span lang=EN-US
  style='font-size:14.0pt;line-height:200%'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></b><b><span
  style='font-size:14.0pt;line-height:200%;font-family:宋体'>名：$apply[apply_name]</span></b></p>
  <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
  line-height:200%;font-family:宋体'>身份证号：</span></b><b><span lang=EN-US
  style='font-size:14.0pt;line-height:200%'>$apply[apply_idcard]</span></b></p>
  <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
  line-height:200%;font-family:宋体'>考试地点：$recruit[interview_addr]</span></b></p>
  <p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
  style='font-size:14.0pt;line-height:200%'>&nbsp;</span></b></p>
  <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
  line-height:200%;font-family:宋体'>考</span></b><b><span lang=EN-US
  style='font-size:14.0pt;line-height:200%'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></b><b><span
  style='font-size:14.0pt;line-height:200%;font-family:宋体'>场：</span></b><b><span
  lang=EN-US style='font-size:14.0pt;line-height:200%'>$apply[interview_room]</span></b></p>
  <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
  line-height:200%;font-family:宋体'>报考岗位：$post_name</span></b></p>
  <p class=MsoNormal style='line-height:200%'><b><span style='font-size:14.0pt;
  line-height:200%;font-family:宋体'>考试时间：</span></b><b><span lang=EN-US
  style='font-size:14.0pt;line-height:200%'>$recruit[interview_time]</span></b></p>
  </td>
 </tr>
 <tr style='height:237.95pt'>
  <td width=569 valign=top style='width:427.0pt;border:solid windowtext 1.5pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:237.95pt'>
  <p class=MsoNormal align=center style='text-align:center;line-height:150%'><span
  style='font-size:16.0pt;line-height:150%;font-family:宋体'>考生须知</span></p>
  <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>一、考试前</span><span
  lang=EN-US>$recruit[interview_ready]</span><span style='font-family:宋体'>，考生凭本人准考证和身份证（有效期内），缺一不可，进入侯考室报到、抽签。身份证丢失的，只能凭临时身份证参加考试，户籍证明、学生证、驾驶证、户口本等其他证件均不能作为考试凭证。超过报到时间</span><span
  lang=EN-US>$recruit[interview_after]</span><span style='font-family:宋体'>分钟未到者视为自动放弃面试资格。</span></p>
  <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>二、考生查验身份进入侯考室后严禁使用各类通讯工具，同时须将通讯工具关闭并装入指定信封（信封上写明姓名和面试号），交工作人员统一保管，面试结束后交还。候考人员一律在侯考室待考，自觉遵守侯考室纪律，不得随意外出，不得以任何形式与外界联系，不得进行可能导致有失面试公正的活动，如有发现违反规定者一律按作弊处理。</span></p>
  <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>三、考生须按抽签顺序并由工作人员引领进入面试考场参加面试。在面试过程中，“面试号码”代替考生姓名。考生进入面试现场后，须先报面试号码，不得透漏姓名、工作单位和学校等个人信息。</span></p>
  <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>四、面试采用结构化面试，每人面试时间为</span><span
  lang=EN-US>$recruit[interview_length]</span><span style='font-family:宋体'>。</span></p>
  <p class=MsoNormal style='text-indent:21.0pt'><span style='font-family:宋体'>五、面试结束后须由工作人员引领至休息室，休息室不得喧哗。面试成绩公布后回侯考室领取本人物品离开考场。</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>

</div>

</body>

</html>
        ";
    
        ob_start();
        echo $content;
        $data = ob_get_contents();
        ob_end_clean();
        $id=$apply['apply_id'];
        $word_name="public/exam/$id.doc";
        $fp=fopen($word_name,"wb");
        fwrite($fp,$data);
        fclose($fp);
        //更改状态
        $a['updatetime']=time();
        $a['status']='interview_downloaded';
        $apply=model('Apply')->where('apply_id',$id)->update($a);
        
    
        $p=config('view_replace_str')['__ROOT__'];
        $word_name=$_SERVER['HTTP_HOST']."$p/".$word_name;
//         dump($p);die;
        $this->redirect('http://'.$word_name);
    }
    
    
}
